enum hvm_access_type access_type,
struct hvm_emulate_ctxt *hvmemul_ctxt)
{
+ struct vcpu *curr = current;
unsigned long addr;
+ paddr_t gpa;
int rc;
rc = hvmemul_virtual_to_linear(
*val = 0;
+ if ( unlikely(curr->arch.hvm_vcpu.mmio_gva == (addr & PAGE_MASK)) &&
+ curr->arch.hvm_vcpu.mmio_gva )
+ {
+ unsigned int off = addr & (PAGE_SIZE - 1);
+ if ( access_type == hvm_access_insn_fetch )
+ return X86EMUL_UNHANDLEABLE;
+ gpa = (((paddr_t)curr->arch.hvm_vcpu.mmio_gpfn << PAGE_SHIFT) | off);
+ if ( (off + bytes) <= PAGE_SIZE )
+ return hvmemul_do_mmio(gpa, 1, bytes, 0, IOREQ_READ, 0, 0, val);
+ }
+
rc = ((access_type == hvm_access_insn_fetch) ?
hvm_fetch_from_guest_virt(val, addr, bytes) :
hvm_copy_from_guest_virt(val, addr, bytes));
if ( rc == HVMCOPY_bad_gfn_to_mfn )
{
unsigned long reps = 1;
- paddr_t gpa;
if ( access_type == hvm_access_insn_fetch )
return X86EMUL_UNHANDLEABLE;
{
struct hvm_emulate_ctxt *hvmemul_ctxt =
container_of(ctxt, struct hvm_emulate_ctxt, ctxt);
+ struct vcpu *curr = current;
unsigned long addr;
+ paddr_t gpa;
int rc;
rc = hvmemul_virtual_to_linear(
if ( rc != X86EMUL_OKAY )
return rc;
+ if ( unlikely(curr->arch.hvm_vcpu.mmio_gva == (addr & PAGE_MASK)) &&
+ curr->arch.hvm_vcpu.mmio_gva )
+ {
+ unsigned int off = addr & (PAGE_SIZE - 1);
+ gpa = (((paddr_t)curr->arch.hvm_vcpu.mmio_gpfn << PAGE_SHIFT) | off);
+ if ( (off + bytes) <= PAGE_SIZE )
+ return hvmemul_do_mmio(gpa, 1, bytes, val, IOREQ_WRITE,
+ 0, 0, NULL);
+ }
+
rc = hvm_copy_to_guest_virt(addr, &val, bytes);
if ( rc == HVMCOPY_bad_gva_to_gfn )
return X86EMUL_EXCEPTION;
if ( rc == HVMCOPY_bad_gfn_to_mfn )
{
unsigned long reps = 1;
- paddr_t gpa;
rc = hvmemul_linear_to_phys(
addr, &gpa, bytes, &reps, hvm_access_write, hvmemul_ctxt);
rc = hvm_emulate_one(&ctxt);
if ( curr->arch.hvm_vcpu.io_state == HVMIO_awaiting_completion )
- curr->arch.hvm_vcpu.io_state = HVMIO_handle_mmio_awaiting_completion;
+ curr->arch.hvm_vcpu.io_state = HVMIO_handle_mmio_awaiting_completion;
+ else
+ curr->arch.hvm_vcpu.mmio_gva = 0;
switch ( rc )
{
return 1;
}
+int handle_mmio_with_translation(unsigned long gva, unsigned long gpfn)
+{
+ current->arch.hvm_vcpu.mmio_gva = gva & PAGE_MASK;
+ current->arch.hvm_vcpu.mmio_gpfn = gpfn;
+ return handle_mmio();
+}
+
void hvm_io_assist(void)
{
struct vcpu *v = current;
perfc_incr(shadow_fault_fast_mmio);
SHADOW_PRINTK("fast path mmio %#"PRIpaddr"\n", gpa);
reset_early_unshadow(v);
- return handle_mmio() ? EXCRET_fault_fixed : 0;
+ return (handle_mmio_with_translation(va, gpa >> PAGE_SHIFT)
+ ? EXCRET_fault_fixed : 0);
}
else
{
shadow_audit_tables(v);
reset_early_unshadow(v);
shadow_unlock(d);
- return handle_mmio() ? EXCRET_fault_fixed : 0;
+ return (handle_mmio_with_translation(va, gpa >> PAGE_SHIFT)
+ ? EXCRET_fault_fixed : 0);
not_a_shadow_fault:
sh_audit_gw(v, &gw);